package com.wjl.maker.generator;

import lombok.val;

import java.io.*;

public class JarGenerator {

    public  static void doGenerate(String projectDir) throws IOException, InterruptedException {
        String winCmd="mvn.cmd clean package -DskipTests=true";
        String otherCmd="mvn clean package -DskipTests=true";
        ProcessBuilder processBuilder = new ProcessBuilder(otherCmd.split(" "));
        processBuilder.directory(new File(projectDir));
        Process process = processBuilder.start();
        InputStream inputStream = process.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            System.out.println(line);
        }
        int i = process.waitFor();
        System.out.println("命令结束，退出码："+i);
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        doGenerate("/Users/wangjilin/code/java/yuzi-generator/yuzi-generator-maker/generated");
    }
}
